from overfish.libs.ModelValidationException import ModelValidationException
u"""
OverFish CMS

Created on: 2011-07-07

@author: Tomas Holub (tomas.holub@olc.cz)
@package: modArticle
u"""

from overfish.libs.BaseModel import BaseModel

class Article(BaseModel):
    u"""
    Article model
    """
    
    def __init__(self, connection = None, database = None):
        BaseModel.__init__(self, u"article", connection, database)
    
    def validate(self, data):
        
        if BaseModel.validate(self, data) == True:
        
            if not data.has_key(u"title"):
                raise ModelValidationException(u"Field is required", self.getCollection(), u"title")
            
            return True
        else:
            return False
        